<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>XMind 转 Excel/CSV 工具</title>
    <link rel="stylesheet" href="https://cdn.bootcdn.net/ajax/libs/font-awesome/6.7.2/css/all.min.css">
    <style>
        /* 基础样式和变量 */
        :root {
            --primary-color: #4a6fa5;
            --secondary-color: #6c8ebd;
            --background-color: #f5f7fa;
            --card-background: #ffffff;
            --text-color: #333333;
            --border-color: #e0e0e0;
            --error-color: #e74c3c;
            --success-color: #2ecc71;
            --shadow-color: rgba(0, 0, 0, 0.1);
            --font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
            --tip-background: #e3f2fd;
        }
        
        /* 暗黑模式变量 */
        [data-theme="dark"] {
            --primary-color: #5b8ad6;
            --secondary-color: #7fa3d7;
            --background-color: #1a1a2e;
            --card-background: #222438;
            --text-color: #e0e0e0;
            --border-color: #444444;
            --shadow-color: rgba(0, 0, 0, 0.3);
            --tip-background: #1a2a3a;
        }
        
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }
        
        body {
            font-family: var(--font-family);
            background-color: var(--background-color);
            color: var(--text-color);
            line-height: 1.6;
            transition: background-color 0.3s, color 0.3s;
        }
        
        .container {
            max-width: 1400px;
            margin: 0 auto;
            padding: 20px;
            min-height: 100vh;
            display: flex;
            flex-direction: column;
        }
        
        /* 头部样式 */
        header {
            padding-bottom: 15px;
            padding-top: 15px;
            border-bottom: 1px solid var(--border-color);
            background-color: var(--card-background);
            position: relative;
            z-index: 1000;
        }

        /* 头部左侧区域 */
        .header-container {
            max-width: 1400px;
            margin: 0 auto;
            padding: 0 20px;
            display: flex;
            justify-content: space-between;
            align-items: center;
            width: 100%;
        }

        .header-left {
            display: flex;
            align-items: center;
            gap: 30px;
        }

        /* Logo样式 */
        .logo {
            font-size: 18px;
            font-weight: bold;
            padding: 8px 12px;
            border-radius: 6px;
        }

        /* 主导航样式 */
        .main-navigation {
            display: flex;
            gap: 0;
        }

        .nav-item {
            position: relative;
        }

        .nav-link {
            display: flex;
            align-items: center;
            gap: 5px;
            padding: 10px 15px;
            color: var(--text-color);
            text-decoration: none;
            font-size: 14px;
            font-weight: 500;
            transition: all 0.3s ease;
            border-radius: 4px;
        }

        .nav-link:hover {
            background-color: var(--tip-background);
            color: var(--primary-color);
        }

        .nav-link i {
            font-size: 12px;
            transition: transform 0.3s ease;
        }

        /* 下拉菜单样式 */
        .dropdown-menu {
            position: absolute;
            top: 100%;
            left: 0;
            min-width: 180px;
            background-color: var(--card-background);
            border: 1px solid var(--border-color);
            border-radius: 6px;
            box-shadow: 0 4px 12px var(--shadow-color);
            opacity: 0;
            visibility: hidden;
            transform: translateY(-10px);
            transition: all 0.3s ease;
            z-index: 1001;
        }

        .dropdown:hover .dropdown-menu {
            opacity: 1;
            visibility: visible;
            transform: translateY(0);
        }

        .dropdown:hover .nav-link i {
            transform: rotate(180deg);
        }

        .dropdown-menu a {
            display: block;
            padding: 10px 15px;
            color: var(--text-color);
            text-decoration: none;
            font-size: 13px;
            transition: all 0.2s ease;
            border-bottom: 1px solid var(--border-color);
        }

        .dropdown-menu a:last-child {
            border-bottom: none;
        }

        .dropdown-menu a:hover {
            background-color: var(--tip-background);
            color: var(--primary-color);
            padding-left: 20px;
        }
        
        /* 主内容区域 */
        main {
            flex: 1;
        }
        
        .converter-container {
            display: flex;
            flex-direction: column;
            gap: 20px;
        }
        
        .converter-section {
            background-color: var(--card-background);
            border-radius: 8px;
            box-shadow: 0 4px 6px var(--shadow-color);
            padding: 20px;
            transition: background-color 0.3s, box-shadow 0.3s;
        }
        
        .converter-section h2 {
            font-size: 18px;
            margin-bottom: 15px;
            display: flex;
            align-items: center;
            gap: 8px;
        }
        
        .input-group {
            display: flex;
            flex-direction: column;
            margin-bottom: 15px;
        }
        
        .input-group label {
            margin-bottom: 5px;
            font-weight: 500;
        }
        
        .input-group input, .input-group textarea {
            padding: 10px;
            border: 1px solid var(--border-color);
            border-radius: 4px;
            background-color: var(--input-bg);
            color: var(--text-color);
            font-size: 14px;
            transition: border-color 0.3s;
        }
        
        .input-group input:focus, .input-group textarea:focus {
            outline: none;
            border-color: var(--primary-color);
        }
        
        .input-group button {
            padding: 10px 15px;
            border: none;
            border-radius: 4px;
            background-color: var(--primary-color);
            color: white;
            cursor: pointer;
            font-size: 14px;
            display: flex;
            align-items: center;
            gap: 5px;
            transition: background-color 0.3s, transform 0.1s;
        }
        
        .input-group button:hover {
            background-color: var(--primary-hover);
        }
        
        .input-group button:active {
            transform: scale(0.98);
        }
        
        /* 文件上传区域样式 */
        .file-upload-area {
            border: 2px dashed var(--border-color);
            border-radius: 8px;
            padding: 40px;
            text-align: center;
            background-color: var(--tip-background);
            transition: all 0.3s ease;
            cursor: pointer;
            margin-bottom: 20px;
        }
        
        .file-upload-area:hover {
            border-color: var(--primary-color);
            background-color: var(--primary-color);
            color: white;
        }
        
        .file-upload-area.dragover {
            border-color: var(--primary-color);
            background-color: var(--primary-color);
            color: white;
        }
        
        .file-upload-area i {
            font-size: 48px;
            margin-bottom: 15px;
            display: block;
        }
        
        .file-upload-area p {
            font-size: 16px;
            margin-bottom: 10px;
        }
        
        .file-upload-area small {
            font-size: 12px;
            opacity: 0.8;
        }
        
        #file-input {
            display: none;
        }
        
        /* 文件信息显示 */
        .file-info {
            background-color: var(--tip-background);
            border-radius: 6px;
            padding: 15px;
            margin-bottom: 20px;
            display: none;
        }
        
        .file-info h4 {
            margin-bottom: 10px;
            color: var(--primary-color);
        }
        
        .file-info p {
            margin: 5px 0;
            font-size: 14px;
        }
        
        /* 转换结果预览 */
        .preview-area {
            background-color: var(--card-background);
            border: 1px solid var(--border-color);
            border-radius: 6px;
            padding: 15px;
            margin-bottom: 20px;
            max-height: 400px;
            overflow-y: auto;
            display: none;
        }
        
        .preview-area h4 {
            margin-bottom: 15px;
            color: var(--primary-color);
        }
        
        .preview-table {
            width: 100%;
            border-collapse: collapse;
            font-size: 12px;
        }
        
        .preview-table th,
        .preview-table td {
            border: 1px solid var(--border-color);
            padding: 8px;
            text-align: left;
        }
        
        .preview-table th {
            background-color: var(--tip-background);
            font-weight: 600;
        }
        
        /* 下载按钮组 */
        .download-buttons {
            display: flex;
            gap: 10px;
            flex-wrap: wrap;
            margin-top: 20px;
        }
        
        .download-buttons button {
            padding: 12px 20px;
            border: none;
            border-radius: 6px;
            background-color: var(--success-color);
            color: white;
            cursor: pointer;
            font-size: 14px;
            display: flex;
            align-items: center;
            gap: 8px;
            transition: all 0.3s ease;
        }
        
        .download-buttons button:hover {
            background-color: #27ae60;
            transform: translateY(-2px);
        }
        
        .download-buttons button:disabled {
            background-color: #bdc3c7;
            cursor: not-allowed;
            transform: none;
        }
        
        /* 复制通知 */
        .copy-notification {
            position: fixed;
            bottom: 20px;
            right: 20px;
            background-color: var(--success-color);
            color: white;
            padding: 10px 20px;
            border-radius: 4px;
            box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
            transform: translateY(100px);
            opacity: 0;
            transition: transform 0.3s, opacity 0.3s;
        }
        
        .copy-notification.show {
            transform: translateY(0);
            opacity: 1;
        }
        
        .header-controls {
            display: flex;
            align-items: center;
            gap: 15px;
        }
        
        /* 主题切换开关 */
        .theme-toggle {
            position: relative;
        }
        
        .theme-switch {
            opacity: 0;
            position: absolute;
        }
        
        .theme-switch-label {
            display: flex;
            align-items: center;
            justify-content: space-between;
            cursor: pointer;
            width: 50px;
            height: 26px;
            background-color: #83d8ff;
            border-radius: 100px;
            position: relative;
            transition: background-color 0.3s;
            padding: 0 5px;
        }
        
        .theme-switch:checked + .theme-switch-label {
            background-color: #4a4e69;
        }
        
        .theme-switch-label .fa-sun {
            color: #f39c12;
        }
        
        .theme-switch-label .fa-moon {
            color: #f1c40f;
        }
        
        .theme-switch-label .slider {
            position: absolute;
            width: 22px;
            height: 22px;
            border-radius: 50%;
            transition: 0.3s;
            background-color: white;
            box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
            left: 2px;
        }
        
        .theme-switch:checked + .theme-switch-label .slider {
            transform: translateX(24px);
        }
        
        /* 分享按钮 */
        .share-button {
            display: flex;
            align-items: center;
            gap: 8px;
            padding: 2px 6px;
            background-color: var(--secondary-color);
            color: white;
            border-radius: 15px;
            cursor: pointer;
            font-size: 14px;
            transition: background-color 0.3s, transform 0.1s;
        }
        
        .share-button:hover {
            background-color: var(--primary-color);
        }
        
        .share-button:active {
            transform: scale(0.98);
        }
        
        .share-button i {
            font-size: 16px;
        }
        
        /* 隐私提示框样式 */
        .privacy-notice {
            margin-bottom: 20px;
            animation: fadeIn 0.5s ease-in-out;
        }
        
        .privacy-notice-content {
            display: flex;
            align-items: center;
            background-color: var(--tip-background);
            border-left: 4px solid #2196f3;
            padding: 15px;
            border-radius: 4px;
            box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
            position: relative;
        }
        
        .privacy-notice-content i.fa-shield-alt {
            font-size: 20px;
            color: #2196f3;
            margin-right: 15px;
        }
        
        .privacy-notice-content p {
            flex: 1;
            margin: 0;
            font-size: 14px;
            color: var(--text-color);
        }
        
        .close-notice {
            background: none;
            border: none;
            color: #90a4ae;
            cursor: pointer;
            font-size: 16px;
            padding: 5px;
            display: flex;
            align-items: center;
            justify-content: center;
            transition: color 0.2s;
        }
        
        .close-notice:hover {
            color: #546e7a;
            background: none;
        }
        
        @keyframes fadeIn {
            from {
                opacity: 0;
                transform: translateY(-10px);
            }
            to {
                opacity: 1;
                transform: translateY(0);
            }
        }
        
        /* 页脚样式 */
        footer {
            background-color: var(--card-background);
            color: var(--text-color);
            padding: 40px 0 20px;
            margin-top: auto;
            border-top: 1px solid var(--border-color);
        }

        .footer-container {
            max-width: 1400px;
            margin: 0 auto;
            padding: 0 20px;
        }

        .footer-main {
            display: flex;
            justify-content: space-between;
            gap: 40px;
            margin-bottom: 30px;
            flex-wrap: wrap;
        }

        .footer-section {
            flex: 1;
            min-width: 220px;
        }

        .footer-section h3 {
            font-size: 16px;
            margin-bottom: 20px;
            color: var(--text-color);
            font-weight: 600;
            position: relative;
            padding-bottom: 10px;
        }

        .footer-section h3::after {
            content: '';
            position: absolute;
            left: 0;
            bottom: 0;
            width: 30px;
            height: 2px;
            background-color: var(--primary-color);
        }

        .footer-section p {
            font-size: 14px;
            line-height: 1.8;
            color: var(--text-color);
            opacity: 0.8;
        }

        .footer-section.about-us {
            flex-basis: 8%;
        }

        .footer-section.links ul {
            list-style: none;
            padding: 0;
            margin: 0;
        }

        .footer-section.links .links-columns {
            display: flex;
            gap: 40px;
        }

        .footer-section.links li {
            margin-bottom: 10px;
        }

        .footer-section.links a {
            color: var(--text-color);
            opacity: 0.8;
            text-decoration: none;
            font-size: 14px;
            transition: color 0.3s, padding-left 0.3s, opacity 0.3s;
        }

        .footer-section.links a:hover {
            color: var(--primary-color);
            padding-left: 5px;
            opacity: 1;
        }

        .social-icons {
            display: flex;
            gap: 15px;
            margin-bottom: 15px;
        }

        .social-icons a {
            color: var(--text-color);
            opacity: 0.8;
            font-size: 20px;
            transition: color 0.3s, transform 0.3s, opacity 0.3s;
        }

        .social-icons a:hover {
            color: var(--primary-color);
            transform: translateY(-2px);
            opacity: 1;
        }

        .footer-bottom {
            display: flex;
            justify-content: space-between;
            align-items: center;
            padding-top: 20px;
            border-top: 1px solid var(--border-color);
            font-size: 13px;
            color: var(--text-color);
            opacity: 0.7;
            flex-wrap: wrap;
            gap: 10px;
        }

        .footer-legal a {
            color: var(--text-color);
            opacity: 0.7;
            text-decoration: none;
            margin-left: 15px;
            transition: color 0.3s, opacity 0.3s;
        }

        .footer-legal a:hover {
            color: var(--primary-color);
            opacity: 1;
        }
        
        /* 响应式设计 */
        @media (max-width: 768px) {
            .header-left {
                flex-direction: column;
                gap: 15px;
                align-items: flex-start;
            }
            
            .main-navigation {
                flex-wrap: wrap;
                gap: 5px;
            }
            
            .nav-link {
                padding: 8px 12px;
                font-size: 13px;
            }
            
            .dropdown-menu {
                position: static;
                opacity: 1;
                visibility: visible;
                transform: none;
                box-shadow: none;
                border: none;
                background-color: transparent;
                min-width: auto;
            }
            
            .dropdown:hover .dropdown-menu {
                display: block;
            }
            
            .input-group {
                flex-direction: column;
                align-items: flex-start;
            }

            .input-group label {
                margin-bottom: 5px;
            }

            .input-group button {
                margin-top: 10px;
            }

            .privacy-notice-content {
                flex-direction: column;
                text-align: center;
                padding: 15px 10px;
            }
            
            .privacy-notice-content i.fa-shield-alt {
                margin-right: 0;
                margin-bottom: 10px;
            }
            
            .close-notice {
                position: absolute;
                top: 5px;
                right: 5px;
            }

            header {
                flex-direction: column;
                gap: 15px;
                text-align: center;
            }
            
            .download-buttons {
                justify-content: center;
            }
        }
    </style>
    <script type="text/javascript" charset="UTF-8" src="https://cdn.wwads.cn/js/makemoney.js" async></script>
</head>
<body>
    <header>
        <div class="header-container">
            <div class="header-left">
                <div class="logo">
                    <span><a href="https://geekdaxue.co/" target="_blank"><img src="https://geekdaxue.co/static/images/logo_platypus.png" height="30px"></a></span>
                </div>
                <nav class="main-navigation">
                    <div class="nav-item dropdown">
                        <a href="#" class="nav-link">
                            JSON工具 <i class="fas fa-chevron-down"></i>
                        </a>
                        <div class="dropdown-menu">
                            <a href="../json/index.html">JSON 格式化</a>
                            <a href="../json/parser.html">JSON 格式校验</a>
                            <a href="../json/excel.html">JSON 转 Excel/CSV</a>
                            <a href="../json/jsonxml.html">JSON 与 XML 转换</a>
                            <a href="../json/editor.html">JSON 编辑器</a>
                        </div>
                    </div>
                    <div class="nav-item dropdown">
                        <a href="#" class="nav-link">
                            编码转换 <i class="fas fa-chevron-down"></i>
                        </a>
                        <div class="dropdown-menu">
                            <a href="../coding/base64.html">Base64 编码</a>
                            <a href="../coding/urlencoding.html">URL 编码</a>
                            <a href="../coding/md5.html">MD5 加密</a>
                            <a href="../coding/unicode.html">Unicode 转换</a>
                            <a href="../coding/hex_convert.html">进制转换</a>
                            <a href="../coding/xmind2excel.html">XMind 转 Excel</a>
                        </div>
                    </div>
                    <div class="nav-item dropdown">
                        <a href="#" class="nav-link">
                            文本工具 <i class="fas fa-chevron-down"></i>
                        </a>
                        <div class="dropdown-menu">
                            <a href="../txt/diff.html">文本对比</a>
                            <a href="../txt/replace.html">文本替换</a>
                            <a href="../txt/remove.html">空白行移除</a>
                            <a href="../txt/cn_trans.html">繁简体转换</a>
                        </div>
                    </div>
                    <div class="nav-item dropdown">
                        <a href="#" class="nav-link">
                            图片工具 <i class="fas fa-chevron-down"></i>
                        </a>
                        <div class="dropdown-menu">
                            <a href="../img/2svg.html">图片转 SVG</a>
                            <a href="../img/qr_code.html">二维码生成</a>
                            <a href="../img/barcode.html">条形码生成</a>
                        </div>
                    </div>
                </nav>
            </div>
            <div class="header-controls">
                <div class="theme-toggle">
                    <input type="checkbox" id="theme-switch" class="theme-switch">
                    <label for="theme-switch" class="theme-switch-label">
                        <i class="fas fa-sun"></i>
                        <i class="fas fa-moon"></i>
                        <span class="slider"></span>
                    </label>
                </div>
                <div class="share-button" id="share-button" title="分享给朋友">
                    <i class="fas fa-share-alt"></i>
                    <span>分享</span>
                </div>
            </div>
        </div>
    </header>

    <div class="container">    
        <h1>XMind 转 Excel/CSV 工具</h1>
        <div id="privacy-notice" class="privacy-notice">
            <div class="privacy-notice-content">
                <i class="fas fa-shield-alt"></i>
                <p>安全提示：您的文件仅在本地浏览器中处理，不会上传到服务器，请放心使用！</p>
                <button id="close-notice" class="close-notice" title="关闭提示">
                    <i class="fas fa-times"></i>
                </button>
            </div>
        </div>
        
        <main>
            <div class="converter-section">
                <h2><i class="fas fa-file-upload"></i> 上传 XMind 文件</h2>
                
                <!-- 文件上传区域 -->
                <div class="file-upload-area" id="file-upload-area">
                    <i class="fas fa-cloud-upload-alt"></i>
                    <p>点击或拖拽 XMind 文件到此处</p>
                    <small>支持 .xmind 格式文件</small>
                </div>
                <input type="file" id="file-input" accept=".xmind" />
                
                <!-- 文件信息显示 -->
                <div class="file-info" id="file-info">
                    <h4><i class="fas fa-info-circle"></i> 文件信息</h4>
                    <p id="file-name">文件名：</p>
                    <p id="file-size">文件大小：</p>
                    <p id="file-type">文件类型：</p>
                </div>
                
                <!-- 转换结果预览 -->
                <div class="preview-area" id="preview-area">
                    <h4><i class="fas fa-eye"></i> 转换预览</h4>
                    <div id="preview-content"></div>
                </div>
                
                <!-- 下载按钮组 -->
                <div class="download-buttons">
                    <button id="download-xlsx" disabled>
                        <i class="fas fa-file-excel"></i> 下载 Excel (.xlsx)
                    </button>
                    <button id="download-csv" disabled>
                        <i class="fas fa-file-csv"></i> 下载 CSV (.csv)
                    </button>
                </div>
            </div>
        </main>
        <div class="wwads-cn wwads-horizontal" data-id="321" style="max-width:350px"></div>
    </div>
    
    <footer>
        <div class="footer-container">
            <div class="footer-main">
                <div class="footer-section about-us">
                    <h3>关于我们</h3>
                    <p>我们提供一系列高效、便捷的在线工具，帮助开发者、非技术人员提高工作效率，解决日常开发中遇到的各种问题。</p>
                    <p>Build With <i class="fa-solid fa-heart" style="color: red;"></i> For SF.</p>
                </div>
                <div class="footer-section links">
                    <h3>工具导航</h3>
                    <div class="links-columns">
                        <ul>
                            <li><a href="../json/index.html">JSON 工具</a></li>
                            <li><a href="../img/index.html">图片处理</a></li>
                            <li><a href="#">开发工具</a></li>
                        </ul>
                        <ul>
                            <li><a href="../coding/index.html">编码转换</a></li>
                            <li><a href="../txt/index.html">文本工具</a></li>
                        </ul>
                    </div>
                </div>
                <div class="footer-section contact">
                    <h3>联系我们</h3>
                    <div class="social-icons">
                        <a href="#" title="GitHub"><i class="fab fa-github"></i></a>
                        <a href="#" title="Twitter"><i class="fab fa-twitter"></i></a>
                        <a href="#" title="WeChat"><i class="fab fa-weixin"></i></a>
                        <a href="mailto:example@example.com" title="Email"><i class="fas fa-envelope"></i></a>
                    </div>
                    <p>如有问题或建议，请随时联系我们</p>
                </div>
            </div>
            <div class="footer-bottom">
                <p>© 2025 XMind 转换工具 Pro. 保留所有权利</p>
                <div class="footer-legal">
                    <a href="#">使用条款</a>
                    <a href="#">隐私政策</a>
                </div>
            </div>
        </div>
    </footer>
    
    <div id="copy-notification" class="copy-notification">操作成功！</div>
    <div id="share-notification" class="copy-notification">已复制网址，赶快让更多的小伙伴知道我吧！</div>
    
    <!-- 引入必要的库 -->
    <script src="https://cdnjs.cloudflare.com/ajax/libs/jszip/3.10.1/jszip.min.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/xlsx/0.18.5/xlsx.full.min.js"></script>
    
    <script>
        document.addEventListener('DOMContentLoaded', function() {
            // 获取DOM元素
            const fileUploadArea = document.getElementById('file-upload-area');
            const fileInput = document.getElementById('file-input');
            const fileInfo = document.getElementById('file-info');
            const fileName = document.getElementById('file-name');
            const fileSize = document.getElementById('file-size');
            const fileType = document.getElementById('file-type');
            const previewArea = document.getElementById('preview-area');
            const previewContent = document.getElementById('preview-content');
            const downloadXlsxBtn = document.getElementById('download-xlsx');
            const downloadCsvBtn = document.getElementById('download-csv');
            const copyNotification = document.getElementById('copy-notification');
            const shareNotification = document.getElementById('share-notification');
            const themeSwitch = document.getElementById('theme-switch');
            const privacyNotice = document.getElementById('privacy-notice');
            const closeNoticeBtn = document.getElementById('close-notice');
            const shareButton = document.getElementById('share-button');
            
            let convertedData = null;
            
            // 检查本地存储中的主题设置
            if (localStorage.getItem('theme') === 'dark') {
                document.documentElement.setAttribute('data-theme', 'dark');
                themeSwitch.checked = true;
            }
            
            // 主题切换功能
            themeSwitch.addEventListener('change', function() {
                if (this.checked) {
                    document.documentElement.setAttribute('data-theme', 'dark');
                    localStorage.setItem('theme', 'dark');
                } else {
                    document.documentElement.removeAttribute('data-theme');
                    localStorage.setItem('theme', 'light');
                }
            });
            
            // 隐私提示框关闭功能
            closeNoticeBtn.addEventListener('click', function() {
                privacyNotice.style.display = 'none';
                localStorage.setItem('privacyNoticeClosed', 'true');
            });
            
            // 检查是否需要显示隐私提示
            if (localStorage.getItem('privacyNoticeClosed') === 'true') {
                privacyNotice.style.display = 'none';
            }
            
            // 文件上传区域点击事件
            fileUploadArea.addEventListener('click', function() {
                fileInput.click();
            });
            
            // 文件拖拽功能
            fileUploadArea.addEventListener('dragover', function(e) {
                e.preventDefault();
                fileUploadArea.classList.add('dragover');
            });
            
            fileUploadArea.addEventListener('dragleave', function(e) {
                e.preventDefault();
                fileUploadArea.classList.remove('dragover');
            });
            
            fileUploadArea.addEventListener('drop', function(e) {
                e.preventDefault();
                fileUploadArea.classList.remove('dragover');
                const files = e.dataTransfer.files;
                if (files.length > 0) {
                    handleFile(files[0]);
                }
            });
            
            // 文件选择事件
            fileInput.addEventListener('change', function(e) {
                if (e.target.files.length > 0) {
                    handleFile(e.target.files[0]);
                }
            });
            
            // 处理文件
            function handleFile(file) {
                if (!file.name.toLowerCase().endsWith('.xmind')) {
                    showNotification(copyNotification, '请选择 .xmind 格式的文件！', true);
                    return;
                }
                
                // 显示文件信息
                fileName.textContent = '文件名：' + file.name;
                fileSize.textContent = '文件大小：' + formatFileSize(file.size);
                fileType.textContent = '文件类型：XMind 思维导图';
                fileInfo.style.display = 'block';
                
                // 解析XMind文件
                parseXMindFile(file);
            }
            
            // 格式化文件大小
            function formatFileSize(bytes) {
                if (bytes === 0) return '0 Bytes';
                const k = 1024;
                const sizes = ['Bytes', 'KB', 'MB', 'GB'];
                const i = Math.floor(Math.log(bytes) / Math.log(k));
                return parseFloat((bytes / Math.pow(k, i)).toFixed(2)) + ' ' + sizes[i];
            }
            
            // 解析XMind文件
            function parseXMindFile(file) {
                const reader = new FileReader();
                reader.onload = function(e) {
                    try {
                        JSZip.loadAsync(e.target.result).then(function(zip) {
                            // XMind文件是一个ZIP压缩包，包含content.xml文件
                            const contentFile = zip.file('content.xml');
                            if (contentFile) {
                                contentFile.async('string').then(function(content) {
                                    parseXMindContent(content, file.name);
                                });
                            } else {
                                showNotification(copyNotification, 'XMind文件格式不正确！', true);
                            }
                        }).catch(function(error) {
                            showNotification(copyNotification, '解析XMind文件失败：' + error.message, true);
                        });
                    } catch (error) {
                        showNotification(copyNotification, '读取文件失败：' + error.message, true);
                    }
                };
                reader.readAsArrayBuffer(file);
            }
            
            // 解析XMind内容
            function parseXMindContent(xmlContent, originalFileName) {
                try {
                    const parser = new DOMParser();
                    const xmlDoc = parser.parseFromString(xmlContent, 'text/xml');
                    
                    // 提取思维导图数据
                    const topics = extractTopics(xmlDoc);
                    
                    if (topics.length === 0) {
                        showNotification(copyNotification, 'XMind文件中没有找到有效的主题内容！', true);
                        return;
                    }
                    
                    // 转换为表格数据
                    convertedData = {
                        data: topics,
                        fileName: originalFileName.replace('.xmind', '')
                    };
                    
                    // 显示预览
                    showPreview(topics);
                    
                    // 启用下载按钮
                    downloadXlsxBtn.disabled = false;
                    downloadCsvBtn.disabled = false;
                    
                    showNotification(copyNotification, '文件解析成功！');
                    
                } catch (error) {
                    showNotification(copyNotification, '解析XMind内容失败：' + error.message, true);
                }
            }
            
            // 提取主题数据 - 只获取最末级节点
            function extractTopics(xmlDoc) {
                const topics = [];
                const topicElements = xmlDoc.querySelectorAll('topic');
                
                // 找出所有最末级节点（没有子topic的节点）
                 const leafTopics = Array.from(topicElements).filter(function(topic) {
                     // 检查是否有直接子节点
                     const childTopics = topic.querySelector('topics');
                     if (!childTopics) return true;
                     const directChildren = childTopics.querySelectorAll(':scope > topic');
                     return directChildren.length === 0;
                 });
                
                leafTopics.forEach(function(topic, index) {
                    const pathArray = getTopicPathArray(topic);
                    
                    // 创建数据对象，每个层级作为一个属性
                    const topicData = {
                        id: index + 1
                    };
                    
                    // 为每个层级创建列
                    pathArray.forEach(function(nodeTitle, levelIndex) {
                        topicData[`节点层级${levelIndex + 1}`] = nodeTitle;
                    });
                    
                    topics.push(topicData);
                });
                
                return topics;
            }
            
            // 获取主题层级
            function getTopicLevel(topicElement) {
                let level = 0;
                let current = topicElement.parentElement;
                
                while (current) {
                    if (current.tagName === 'topic') {
                        level++;
                    }
                    current = current.parentElement;
                }
                
                return level;
            }
            
            // 获取父主题
            function getParentTopic(topicElement) {
                const parentTopic = topicElement.parentElement;
                if (parentTopic && parentTopic.tagName === 'topic') {
                    const titleElement = parentTopic.querySelector('title');
                    return titleElement ? titleElement.textContent.trim() : '未命名父主题';
                }
                return '';
            }
            
            // 获取主题路径数组
            function getTopicPathArray(topicElement) {
                const path = [];
                let current = topicElement;
                
                while (current && current.tagName === 'topic') {
                    const titleElement = current.querySelector(':scope > title');
                    const title = titleElement ? titleElement.textContent.trim() : '未命名';
                    path.unshift(title);
                    
                    // 向上查找父级topic
                    let parent = current.parentElement;
                    while (parent && parent.tagName !== 'topic') {
                        parent = parent.parentElement;
                    }
                    current = parent;
                }
                
                return path;
            }
            
            // 显示预览
            function showPreview(topics) {
                if (topics.length === 0) {
                    previewContent.innerHTML = '<p>没有找到末级节点数据</p>';
                    previewArea.style.display = 'block';
                    return;
                }
                
                // 获取所有可能的列名
                const allColumns = new Set();
                topics.forEach(function(topic) {
                    Object.keys(topic).forEach(function(key) {
                        if (key !== 'id') {
                            allColumns.add(key);
                        }
                    });
                });
                
                // 按节点层级数字排序
                 const sortedColumns = Array.from(allColumns).sort(function(a, b) {
                     const aMatch = a.match(/节点层级(\d+)/);
                     const bMatch = b.match(/节点层级(\d+)/);
                     if (aMatch && bMatch) {
                         return parseInt(aMatch[1]) - parseInt(bMatch[1]);
                     }
                     return a.localeCompare(b);
                 });
                 const columnNames = ['序号'].concat(sortedColumns);
                
                let html = '<table class="preview-table">';
                html += '<thead><tr>';
                columnNames.forEach(function(col) {
                    html += '<th>' + escapeHtml(col) + '</th>';
                });
                html += '</tr></thead>';
                html += '<tbody>';
                
                const displayTopics = topics.slice(0, Math.min(10, topics.length));
                displayTopics.forEach(function(topic) {
                    html += '<tr>';
                    columnNames.forEach(function(col) {
                        if (col === '序号') {
                            html += '<td>' + topic.id + '</td>';
                        } else {
                            html += '<td>' + escapeHtml(topic[col] || '') + '</td>';
                        }
                    });
                    html += '</tr>';
                });
                
                if (topics.length > 10) {
                    html += '<tr><td colspan="' + columnNames.length + '" style="text-align: center; font-style: italic;">... 还有 ' + (topics.length - 10) + ' 行数据</td></tr>';
                }
                
                html += '</tbody></table>';
                
                previewContent.innerHTML = html;
                previewArea.style.display = 'block';
            }
            
            // HTML转义
            function escapeHtml(text) {
                const div = document.createElement('div');
                div.textContent = text;
                return div.innerHTML;
            }
            
            // 下载Excel文件
            downloadXlsxBtn.addEventListener('click', function() {
                if (!convertedData) return;
                
                try {
                    // 准备Excel数据
                    const excelData = convertedData.data.map(function(topic) {
                        const row = { '序号': topic.id };
                        Object.keys(topic).forEach(function(key) {
                            if (key !== 'id') {
                                row[key] = topic[key];
                            }
                        });
                        return row;
                    });
                    
                    const ws = XLSX.utils.json_to_sheet(excelData);
                    
                    // 设置列宽度为默认宽度的一倍（约20个字符宽度）
                    const colWidths = [];
                    const headers = Object.keys(excelData[0] || {});
                    headers.forEach(function() {
                        colWidths.push({ wch: 20 }); // 设置列宽为20个字符
                    });
                    ws['!cols'] = colWidths;
                    
                    const wb = XLSX.utils.book_new();
                    XLSX.utils.book_append_sheet(wb, ws, 'XMind数据');
                    
                    XLSX.writeFile(wb, convertedData.fileName + '.xlsx');
                    showNotification(copyNotification, 'Excel文件下载成功！');
                } catch (error) {
                    showNotification(copyNotification, '生成Excel文件失败：' + error.message, true);
                }
            });
            
            // 下载CSV文件
            downloadCsvBtn.addEventListener('click', function() {
                if (!convertedData) return;
                
                try {
                    const csvContent = convertToCSV(convertedData.data);
                    const blob = new Blob([csvContent], { type: 'text/csv;charset=utf-8;' });
                    const link = document.createElement('a');
                    
                    if (link.download !== undefined) {
                        const url = URL.createObjectURL(blob);
                        link.setAttribute('href', url);
                        link.setAttribute('download', convertedData.fileName + '.csv');
                        link.style.visibility = 'hidden';
                        document.body.appendChild(link);
                        link.click();
                        document.body.removeChild(link);
                        
                        showNotification(copyNotification, 'CSV文件下载成功！');
                    }
                } catch (error) {
                    showNotification(copyNotification, '生成CSV文件失败：' + error.message, true);
                }
            });
            
            // 转换为CSV格式
            function convertToCSV(data) {
                if (data.length === 0) return '';
                
                // 获取所有列名
                const allColumns = new Set();
                data.forEach(function(topic) {
                    Object.keys(topic).forEach(function(key) {
                        allColumns.add(key);
                    });
                });
                
                // 按节点层级数字排序列名，序号放在第一位
                 const sortedColumns = Array.from(allColumns).filter(col => col !== 'id').sort(function(a, b) {
                     const aMatch = a.match(/节点层级(\d+)/);
                     const bMatch = b.match(/节点层级(\d+)/);
                     if (aMatch && bMatch) {
                         return parseInt(aMatch[1]) - parseInt(bMatch[1]);
                     }
                     return a.localeCompare(b);
                 });
                 const headers = ['序号'].concat(sortedColumns);
                
                let csv = headers.join(',') + '\n';
                
                data.forEach(function(topic) {
                    const row = headers.map(function(header) {
                        let value = '';
                        if (header === '序号') {
                            value = topic.id || '';
                        } else {
                            value = topic[header] || '';
                        }
                        // CSV转义处理
                        return '"' + String(value).replace(/"/g, '""') + '"';
                    });
                    csv += row.join(',') + '\n';
                });
                
                return csv;
            }
            
            // 显示通知
            function showNotification(element, message, isError = false) {
                element.textContent = message;
                if (isError) {
                    element.style.backgroundColor = 'var(--error-color)';
                } else {
                    element.style.backgroundColor = 'var(--success-color)';
                }
                element.classList.add('show');
                setTimeout(() => {
                    element.classList.remove('show');
                }, 3000);
            }
            
            // 分享功能
            function shareURL() {
                copyToClipboard(window.location.href);
                shareNotification.classList.add('show');
                setTimeout(() => {
                    shareNotification.classList.remove('show');
                }, 2000);
            }
            
            // 通用复制到剪贴板函数
            function copyToClipboard(text) {
                const textarea = document.createElement('textarea');
                textarea.value = text;
                document.body.appendChild(textarea);
                textarea.select();
                document.execCommand('copy');
                document.body.removeChild(textarea);
            }
            
            // 添加事件监听器
            shareButton.addEventListener('click', shareURL);
        });
    </script>
    
    <script>
        var _hmt = _hmt || [];
        (function() {
          var hm = document.createElement("script");
          hm.src = "https://hm.baidu.com/hm.js?3615c6485313357fe26e486bf42d9ec2";
          var s = document.getElementsByTagName("script")[0]; 
          s.parentNode.insertBefore(hm, s);
        })();
    </script>
</body>
</html>